﻿using Microsoft.EntityFrameworkCore;
using NewRetail.Application.Components.TianQue.Entity;
using NewRetail.Application.Core.Entity;

namespace NewRetail.Application.Components.TianQue
{
    public static class TianQueExtension
    {
        public static void ConfigureTianQueEntities(this ModelBuilder modelBuilder)
        {
            //天阙付款记录
            var infoBuilder = modelBuilder.Entity<TianQuePayRecordEntity>().ConfigBaseEntity();
            infoBuilder.ToTable("tianque_pay_record");
            infoBuilder.Property(x => x.uuid).IsRequired().HasMaxLength(32);
            infoBuilder.Property(x => x.mno).IsRequired().HasMaxLength(15);
            infoBuilder.Property(x => x.orgId).IsRequired().HasMaxLength(8);
            infoBuilder.Property(x => x.tranType).IsRequired().HasMaxLength(100);
            infoBuilder.Property(x => x.tranSts).IsRequired().HasMaxLength(50);
            infoBuilder.Property(x => x.paySource).IsRequired().HasMaxLength(50);
            infoBuilder.Property(x => x.ordNo).HasMaxLength(64);
            infoBuilder.Property(x => x.tranSeqNo).IsRequired().HasMaxLength(32);
            infoBuilder.Property(x => x.ouuid).HasMaxLength(32);
            infoBuilder.Property(x => x.tranDt).IsRequired().HasMaxLength(20);
            infoBuilder.Property(x => x.tranTm).IsRequired().HasMaxLength(20);
            infoBuilder.Property(x => x.cardNo).IsRequired();
            infoBuilder.Property(x => x.trmNo).IsRequired().HasMaxLength(100);
            infoBuilder.Property(x => x.batNo).IsRequired().HasMaxLength(50);
            infoBuilder.Property(x => x.posSeqNo).IsRequired().HasMaxLength(100);
            infoBuilder.Property(x => x.searchNo).IsRequired().HasMaxLength(100);
            infoBuilder.Property(x => x.authCode).HasMaxLength(150);
            infoBuilder.Property(x => x.payType).HasMaxLength(50);
            infoBuilder.Property(x => x.mecFeeRate).HasMaxLength(100);
            infoBuilder.Property(x => x.crdTyp).IsRequired().HasMaxLength(50);
            infoBuilder.Property(x => x.tranAmt).IsRequired();
            infoBuilder.Property(x => x.sign).IsRequired();
            infoBuilder.OwnsOne(f => f.bizOrderInfo, o =>
            {
                o.Property(p => p.bizTqNo).IsRequired().HasMaxLength(50);
            });


        }
    }
}
